# Maintainer: Morten Linderud <foxboron@archlinux.org>

pkgname=python-formencode
_pkgname=formencode
_pypi=FormEncode
pkgver=2.0.1
pkgrel=4
pkgdesc="A validation library for Python."
arch=("any")
url="http://www.formencode.org/en/latest/"
license=("MIT")
depends=("python" "python-six")
checkdepends=("python-pytest" "python-dnspython" "python-pycountry")
makedepends=('python-build' 'python-installer' 'python-wheel' 'python-setuptools' 'python-setuptools-scm')
source=("$pkgname-$pkgver.tar.gz::https://github.com/formencode/formencode/archive/$pkgver.tar.gz")
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/${_pkgname}/${_pypi}-${pkgver}.tar.gz")
sha256sums=('8f2974112c2557839d5bae8b76490104c03830785d923abbdef148bf3f710035')

prepare() {
  cd "${_pypi}-${pkgver}"
  sed '/setuptools_scm_git_archive/d' -i setup.py 
}

build() {
  cd "${_pypi}-${pkgver}"
  python -m build --wheel --no-isolation
}

check(){
  cd "${_pypi}-${pkgver}"
  python -m unittest
}

package() {
  cd "${_pypi}-${pkgver}"
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm0644 LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.txt"
}
